package com.byapp.fast.common.converter;


import com.byapp.fast.common.utils.UUIDGenerator;
import com.byapp.fast.modules.contract.biz.BusinessBiz;
import com.byapp.fast.modules.contract.dto.PayDTO;
import com.byapp.fast.modules.order.dto.OrderDataDTO;
import org.apache.commons.lang3.StringUtils;

public class PayDTOConverter {

    public static PayDTO create(BusinessBiz businessBiz, OrderDataDTO orderDataDTO, String orderId, String result) {
        PayDTO payDTO = new PayDTO();
        String payType = orderDataDTO.getPayType();
        Double quantity = StringUtils.equalsIgnoreCase(payType, "ETH") ? orderDataDTO.getTotalMoney() : 0;
        payDTO.setDappid(businessBiz.getDappid());
        payDTO.setToAddress(businessBiz.getToAddress());
        payDTO.setGasLimit(businessBiz.getGasLimit());
        payDTO.setCallType(orderDataDTO.getCallType());
        payDTO.setCallBack(orderDataDTO.getCallBack());
        payDTO.setPsymbol(payType);
        payDTO.setSymbol(payType);
        payDTO.setOutTradeNum(orderId);
        payDTO.setQuantity(quantity);
        payDTO.setNonce(UUIDGenerator.getUUID());
        payDTO.setContractData(result);
        return payDTO;
    }
}
